#!/bin/bash


if [ ! -d "photos" ]; then
    mkdir photos
fi

if [ -z "$1" ]; then
    FILE="simple.pov"
else
    FILE="$1"
fi

if [ ! -z "$2" ]; then
    REFLECTION="$2"
else
    REFLECTION="6"
fi

if [ ! -e "$FILE" ]; then
    echo "$FILE" does not exist
    exit 1
fi

make Parser
status=$?
if [ $status -ne 0 ]; then
    exit $status
fi

FBASE="${FILE%.*}"
EXT=".tga"

echo phong trace
./raytrace 800 600 -I $FILE -p 0 -r "$REFLECTION"
mv $FBASE$EXT photos/phong.tga

echo gaussian trace
./raytrace 800 600 -I $FILE -p 1 -r "$REFLECTION"
mv $FBASE$EXT photos/gaussian.tga

echo beckmann trace
./raytrace 800 600 -I $FILE -p 2 -r "$REFLECTION"
mv $FBASE$EXT photos/beckmann.tga

echo cooktorrance trace
./raytrace 800 600 -I $FILE -p 3 -r "$REFLECTION"
mv $FBASE$EXT photos/cooktorrance.tga

exit 0
